<template>
  <div>
    <!-- <div class="toptitle">组织编码</div> -->
    <el-form
      :inline="true"
      :model="formInline"
      class="demo-form-inline"
      @keyup.enter.native="search()"
    >
      <el-form-item label="店铺名称">
        <br />
        <br />
        <el-input
          v-model="formInline.storeName"
          placeholder
          style="margin-left: -60px; width: 200px"
        ></el-input>
      </el-form-item>

      <el-form-item label="店铺授权编码">
        <br />
        <br />
        <el-input
          v-model="formInline.authCode"
          placeholder
          style="margin-left: -60px; width: 200px"
        ></el-input>
      </el-form-item>
      <el-form-item label="大区名称">
        <br />
        <br />
        <el-input
          v-model="formInline.upOrgZone"
          placeholder
          style="margin-left: -60px; width: 200px"
        ></el-input>
      </el-form-item>
      <el-form-item label="营销区域名称">
        <br />
        <br />
        <el-input
          v-model="formInline.baseName"
          placeholder
          style="margin-left: -60px; width: 200px"
        ></el-input>
      </el-form-item>
      <el-form-item style="margin-left: 700px; text-align: right">
        <el-button
          type="primary"
          @click="search()"
          size="mini"
          icon="el-icon-search"
          >查询</el-button
        >

        <el-button
          type="primary"
          @click="kong()"
          size="mini"
          icon="el-icon-delete"
          >清空</el-button
        >

        <el-button
          type="success"
          @click="exportExcel()"
          size="mini"
          icon="el-icon-s-data"
          >导出</el-button
        >
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      style="width: 100%; margin-bottom: 20px"
      row-key="goodsTypeId"
      border
      v-loading="loading"
      default-expand-all
      @sort-change="handleSort"
      :render-header="labelHead"
    >
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="60"
      ></el-table-column>
      <el-table-column
        prop="storeName"
        label="店铺名称"
        width="200"
        align="center"
      ></el-table-column>

      <el-table-column
        prop="authCode"
        label="店铺授权编码"
        align="center"
        width="160"
      ></el-table-column>

      <el-table-column
        prop="upOrgZone"
        label="大区名称"
        width="220"
        align="center"
      ></el-table-column>

      <el-table-column
        prop="baseName"
        label="营销区域名称"
        align="center"
        width="150"
      ></el-table-column>

      <el-table-column
        prop="overallSatisfaction"
        label="综合满意度"
        width="200"
        align="center"
        sortable="overallSatisfaction"
      ></el-table-column>

      <el-table-column
        prop="sendQuestionnaire"
        label="发出问卷（份）"
        align="center"
        width="150"
        sortable="send_questionnaire"
      ></el-table-column>
      <el-table-column
        prop="submitQuestionnaire"
        label="提交问卷（份）"
        width="180"
        align="center"
        sortable="submit_questionnaire"
      ></el-table-column>

      <el-table-column
        prop="fillPercentage"
        label="问卷填写率"
        align="center"
        width="120"
        sortable="fill_percentage"
      ></el-table-column>
      <!-- <el-table-column prop="questionnaireDataInfoString" label="问卷满意度" align="right"  ></el-table-column> -->
      <el-table-column
        v-for="(v, index) in this.header"
        :key="index"
        :prop="v.questionnaireSatisfaction"
        :label="v.questionnaireName + '满意度'"
        align="center"
        width="250"
      >
        <template slot-scope="scope">
          <span
            v-for="(item2, index2) in scope.row.questionnaireDataInfos"
            v-if="index2 == index"
          >
            {{
              scope.row.questionnaireDataInfos[index2].questionnaireSatisfaction
            }}
          </span>
        </template>
      </el-table-column>
    </el-table>
    <el-form :inline="true" :model="formInline">
      <el-form-item style="margin-top: 6px"></el-form-item>
    </el-form>
    <div class="block" style="margin-top: -49px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30, 50, 100, 150, 200]"
        :current-page="listQuery.current"
        :page-size="listQuery.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
    <!--添加-->
    <el-dialog title="信息" :visible.sync="dialogVisibleorg" width="50%">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="120px"
      >
        <el-form-item label="分类名称" prop="goodsTypeName">
          <el-input v-model="ruleForm.goodsTypeName" maxlength="20"></el-input>
        </el-form-item>
        <el-form-item label="是否关联活动" prop="isRelatedActivity">
          <el-radio-group v-model="ruleForm.isRelatedActivity" size="mini">
            <el-radio-button label="0">否</el-radio-button>
            <el-radio-button label="1">是</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="展示顺序" prop="sortNo">
          <el-input
            v-model="ruleForm.sortNo"
            type="number"
            :min="this.total + 1"
            @change="
              (data) => {
                ruleForm.sortNo = checkSortNo(data);
              }
            "
          ></el-input>
        </el-form-item>
        <el-form-item label="是否展示(小程序)" prop="ruleForm.isDisplay">
          <el-select v-model="ruleForm.isDisplay">
            <el-option label="不展示" :value="0"></el-option>
            <el-option label="展示" :value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="展示形式(小程序)" prop="displayForm">
          <el-select v-model="ruleForm.displayForm">
            <el-option label="单个陈列" :value="1"></el-option>
            <el-option label="两个陈列" :value="2"></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="分类图标:" prop="tagUrl">
                    <el-row>
                        <el-col style="margin: 10px; 0px; 10px; 0">
                            <el-upload
                                style="margin: 10px;"
                                :action="action"
                                list-type="picture-card"
                                :limit="1"
                                :on-preview="handlePictureCardPreview"
                                :on-success="upLoadPicone"
                                :on-change="handleImgChangeone"
                                :file-list="imgListone"
                                :headers="headers"
                            >
                                <i class="el-icon-plus"></i>
                            </el-upload>
                        </el-col>
                    </el-row>
                </el-form-item>
                <el-form-item label="分类照片:" prop="picUrl">
                    <el-row>
                        <el-col style="margin: 10px; 0px; 10px; 0">
                            <el-upload
                                style="margin: 10px;"
                                :action="action"
                                list-type="picture-card"
                                :limit="1"
                                :on-preview="handlePictureCardPreview"
                                :on-success="upLoadPictwo"
                                :on-change="handleImgChangetwo"
                                :file-list="imgListtwo"
                                :headers="headers"
                            >
                                <i class="el-icon-plus"></i>
                            </el-upload>
                        </el-col>
                    </el-row>
                </el-form-item>-->
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleorg = false" size="mini"
          >取 消</el-button
        >
        <el-button type="primary" @click="confirmEditone()" size="mini"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!--修改-->
    <el-dialog title="信息" :visible.sync="dialogVisibleorgone" width="50%">
      <el-form
        :model="ruleFormorg"
        :rules="rules"
        ref="ruleFormorg"
        label-width="120px"
      >
        <el-form
          :model="ruleFormorg"
          :rules="rules"
          ref="ruleFormorg"
          label-width="120px"
        >
          <el-form-item label="分类名称" prop="goodsTypeName">
            <el-input
              v-model="ruleFormorg.goodsTypeName"
              maxlength="20"
            ></el-input>
          </el-form-item>
          <el-form-item label="是否关联活动" prop="isRelatedActivity">
            <el-radio-group v-model="ruleFormorg.isRelatedActivity" size="mini">
              <el-radio-button label="0">否</el-radio-button>
              <el-radio-button label="1">是</el-radio-button>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="展示顺序" prop="sortNo">
            <el-input
              v-model="ruleFormorg.sortNo"
              type="number"
              :min="this.total + 1"
              @change="
                (data) => {
                  ruleFormorg.sortNo = checkSortNo(data);
                }
              "
            ></el-input>
          </el-form-item>
          <el-form-item label="是否展示" prop="isDisplay">
            <el-select v-model="ruleFormorg.isDisplay">
              <el-option label="不展示" :value="0"></el-option>
              <el-option label="展示" :value="1"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="展示形式" prop="displayForm">
            <el-select v-model="ruleFormorg.displayForm">
              <el-option label="单个陈列" :value="1"></el-option>
              <el-option label="两个陈列" :value="2"></el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="分类图标:" prop="tagUrl">
                        <el-row>
                            <el-col style="margin: 10px; 0px; 10px; 0">
                                <el-upload
                                    style="margin: 10px;"
                                    :action="action"
                                    list-type="picture-card"
                                    :limit="1"
                                    :on-preview="handlePictureCardPreview"
                                    :on-success="upLoadPicone"
                                    :on-change="handleImgChangeone"
                                    :file-list="imgListone"
                                    :headers="headers"
                                    :on-exceed="handleExceed"
                                >
                                    <i class="el-icon-plus"></i>
                                </el-upload>
                            </el-col>
                        </el-row>
                    </el-form-item>
                    <el-form-item label="分类照片:" prop="picUrl">
                        <el-row>
                            <el-col style="margin: 10px; 0px; 10px; 0">
                                <el-upload
                                    style="margin: 10px;"
                                    :action="action"
                                    list-type="picture-card"
                                    :limit="1"
                                    :on-preview="handlePictureCardPreview"
                                    :on-success="upLoadPictwo"
                                    :on-change="handleImgChangetwo"
                                    :file-list="imgListtwo"
                                    :headers="headers"
                                    :on-exceed="handleExceed"
                                >
                                    <i class="el-icon-plus"></i>
                                </el-upload>
                            </el-col>
                        </el-row>
                    </el-form-item>-->
        </el-form>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleorgone = false" size="mini"
          >取 消</el-button
        >
        <el-button type="primary" @click="confirmEdittwo()" size="mini"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisibleImg">
      <img width="100%" :src="dialogImageUrl" alt />
    </el-dialog>
  </div>
</template>

<script>
import {
  questionnaireStatisticalData,
  exportQuestionnaireStatisticalData,
} from '@/api/questionnaireData';
import qs from 'qs';
export default {
  data() {
    return {
      action: `${process.env.VUE_APP_BASE_API}/api/file-service/v1/file/uploadFile`,
      headers: {
        token: localStorage.getItem('token'), //从cookie里获取token，并赋值  Authorization ，而不是token
      },
      tableData: [],
      //动态列头header
      header: [],

      txtVal: '',
      picUrl: '',
      loading: true,
      dialogVisibleorg: false,
      dialogVisibleorgone: false,
      imgListone: [],
      imgListtwo: [],
      ruleForm: {
        goodsTypeId: '',
        goodsTypeName: '',
        isRelatedActivity: 0,
        sortNo: 0,
        tagUrl: '',
        picUrl: '',
        isDisplay: 1,
        displayForm: 1,
        goodsTypeId: '',
        upGoodsType: '',
      },
      orgSeqxia: '',
      ruleFormorg: {
        goodsTypeId: '',
        goodsTypeName: '',
        isRelatedActivity: 0,
        sortNo: 0,
        tagUrl: '',
        picUrl: '',
        isDisplay: 1,
        displayForm: 1,
        goodsTypeId: '',
        upGoodsType: '',
      },
      total: 0,
      options: [],
      optionsone: [],
      listQuery: {
        current: 1,
        size: 100,
      },
      flagorg: false,
      dialogVisible: false,
      dialogVisibleImg: false,
      dialogImageUrl: '',
      formInline: {
        storeName: '',
        authCode: '',
        upOrgZone: '',

        baseName: '',
        ascs: [],
        descs: [],
      },
      rules: {
        goodsTypeName: [
          {
            required: true,
            message: '请输入商品名称',
            trigger: 'blur',
          },
        ],
        // tagUrl: [
        //     { required: true, message: "请上传图标", trigger: "blur" }
        // ],
        // picUrl: [
        //     { required: true, message: "请上传图片", trigger: "blur" }
        // ]
      },
    };
  },
  mounted() {
    this.rolemanageone();
  },
  methods: {
    labelHead(h, { column, index }) {
      //动态表头渲染
      //let l = column.label.length;
      //let f = 12; //每个字大小,其实是每个字的比例值,大概会比字体大小打差不多大
      //column.minWidth = f * l; //字大小乘个数即长度 ,注意不要加px像素，这里minWidth只是一个比例值，不是真正的长度
      //然后将列标题放在一个div块中，注意块的宽度一定要100%，否则表格显示不完全
      return h('span', { class: 'table-head', style: { width: '100%' } }, [
        column.label,
      ]);
    },
    //初始化加载
    exportExcel() {
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          storeName: this.formInline.storeName,
          authCode: this.formInline.authCode,
          upOrgZone: this.formInline.upOrgZone,
          baseName: this.formInline.baseName,
        },
        ascs: this.formInline.ascs,
        descs: this.formInline.descs,
      };
      exportQuestionnaireStatisticalData(data)
        .then((res) => {
          const link = document.createElement('a');
          let blob = new Blob([res], { type: 'application/vnd.ms-excel' });
          link.style.display = 'none';
          //设置连接
          link.href = URL.createObjectURL(blob);
          link.download = '问卷数据列表.xlsx';
          document.body.appendChild(link);
          //模拟点击事件
          link.click();
        })
        .catch((err) => {
          console.log(err);
        });
    },
    rolemanageone() {
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          storeName: this.formInline.storeName,
          authCode: this.formInline.authCode,
          upOrgZone: this.formInline.upOrgZone,
          baseName: this.formInline.baseName,
        },
        ascs: this.formInline.ascs,
        descs: this.formInline.descs,
      };
      questionnaireStatisticalData(data).then((res) => {
        res.records.forEach((item, i) => {
          this.options.push({
            value: item.goodsTypeId,
            label: item.orgName,
          });
        });

        this.loading = false;
        this.total = res.total;
        this.tableData = res.records;
        console.log(this.tableData, 'ppe');
        // 在这里将后台返回的列表头数据直接放到之前定义好的header数组中
        this.header = this.tableData[0].questionnaireDataInfos;
      });

      //   let dataone = {
      //     orgType: "",
      //     orgTypeName: ""
      //   };

      //   getUserOrgType(dataone).then(res => {
      //     res.records.forEach((item, i) => {
      //       this.optionsone.push({
      //         value: item.orgType,
      //         label: item.orgTypeName
      //       });
      //     });
      //   });
    },
    //清空
    kong() {
      this.formInline.storeName = '';
      this.formInline.authCode = '';
      this.formInline.upOrgZone = '';
      this.formInline.baseName = '';
    },
    //查询
    search() {
      this.listQuery.current = 1;
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          storeName: this.formInline.storeName,
          authCode: this.formInline.authCode,
          upOrgZone: this.formInline.upOrgZone,
          baseName: this.formInline.baseName,
        },
        ascs: this.formInline.ascs,
        descs: this.formInline.descs,
      };
      questionnaireStatisticalData(data).then((res) => {
        this.total = res.total;
        this.tableData = res.records;
      });
    },
    //新增分类
    creatoneOrg() {
      this.dialogVisibleorg = !this.dialogVisibleorg;
      this.ruleForm.goodsTypeName = '';
      this.ruleForm.sortNo = this.total + 1;
      (this.ruleForm.picUrl = ''), (this.ruleForm.isDisplay = 1);
      this.ruleForm.displayForm = 1;
      this.imgListtwo = [];
      this.imgListone = [];
    },
    creatoneOrgone(v) {
      console.log(v, 'll');
      this.flagorg = true;
      this.orgSeqxia = v.goodsTypeId;
      this.dialogVisibleorgone = !this.dialogVisibleorgone;
    },
    //修改分类
    changeorg(v) {
      this.dialogVisibleorgone = !this.dialogVisibleorgone;
      var userId = localStorage.getItem('userId');
      var picture = v.picUrl;
      this.imgListtwo = [];
      this.imgListone = [];
      if (v.tagUrl != '' && v.tagUrl != null) {
        let data = {
          name: '',
          url: v.tagUrl,
        };
        this.imgListone.push(data);
      }
      if (picture != '' && picture != null) {
        let data = {
          name: '',
          url: picture,
        };
        this.imgListtwo.push(data);
      }
      this.ruleFormorg.goodsTypeName = v.goodsTypeName;
      this.ruleFormorg.goodsTypeId = v.goodsTypeId;
      this.ruleFormorg.isRelatedActivity = v.isRelatedActivity;
      (this.ruleFormorg.sortNo = v.sortNo),
        (this.ruleFormorg.tagUrl = v.tagUrl),
        (this.ruleFormorg.picUrl = v.picUrl),
        (this.ruleFormorg.isDisplay = v.isDisplay),
        (this.ruleFormorg.displayForm = v.displayForm),
        (this.ruleFormorg.upGoodsType = v.upGoodsType),
        (this.flagorg = false);
    },
    //确认添加
    confirmEditone() {
      //   if (
      //         this.ruleForm.tagUrl == "" ||
      //         this.ruleForm.tagUrl == null
      //     ) {
      //         this.$message.error("请上传图标");
      //         return;
      //     }
      //     if (this.ruleForm.picUrl == "" || this.ruleForm.picUrl == null) {
      //         this.$message.error("请上传图片");
      //         return;
      //     }
      let data = {
        goodsTypeName: this.ruleForm.goodsTypeName,
        isRelatedActivity: this.ruleForm.isRelatedActivity,
        sortNo: this.ruleForm.sortNo,
        tagUrl: this.ruleForm.tagUrl,
        picUrl: this.ruleForm.picUrl,
        isDisplay: this.ruleForm.isDisplay,
        displayForm: this.ruleForm.displayForm,
        goodsTypeId: this.ruleForm.goodsTypeId,
        upGoodsType: this.ruleForm.upGoodsType,
      };
      addGoodsType(data).then((res) => {
        this.$message({
          showClose: true,
          message: '添加成功',
          type: 'success',
        });
        this.dialogVisibleorg = !this.dialogVisibleorg;
        this.rolemanageone();
      });
    },
    //确定修改
    confirmEdittwo() {
      // if (
      //     this.ruleFormorg.tagUrl == "" ||
      //     this.ruleFormorg.tagUrl == null
      // ) {
      //     this.$message.error("请上传图标");
      //     return;
      // }
      // if (
      //     this.ruleFormorg.picUrl == "" ||
      //     this.ruleFormorg.picUrl == null
      // ) {
      //     this.$message.error("请上传图片");
      //     return;
      // }
      if (this.flagorg == false) {
        let dataone = {
          goodsTypeName: this.ruleFormorg.goodsTypeName,
          isRelatedActivity: this.ruleFormorg.isRelatedActivity,
          sortNo: this.ruleFormorg.sortNo,
          picUrl: this.ruleFormorg.picUrl,
          tagUrl: this.ruleFormorg.tagUrl,
          isDisplay: this.ruleFormorg.isDisplay,
          displayForm: this.ruleFormorg.displayForm,
          goodsTypeId: this.ruleFormorg.goodsTypeId,
        };
        addGoodsType(dataone).then((res) => {
          this.dialogVisibleorgone = !this.dialogVisibleorgone;
          this.$message({
            showClose: true,
            message: '修改成功',
            type: 'success',
          });
          this.rolemanageone();
        });
      } else if (this.flagorg == true) {
        let data = {
          goodsTypeName: this.ruleFormorg.goodsTypeName,
          isRelatedActivity: this.ruleFormorg.isRelatedActivity,
          sortNo: this.ruleFormorg.sortNo,
          tagUrl: this.ruleFormorg.tagUrl,
          picUrl: this.ruleFormorg.picUrl,
          isDisplay: this.ruleFormorg.isDisplay,
          displayForm: this.ruleFormorg.displayForm,
          goodsTypeId: this.ruleFormorg.goodsTypeId,
          upGoodsType: this.orgSeqxia,
        };
        addGoodsType(data).then((res) => {
          this.$message({
            showClose: true,
            message: '添加成功',
            type: 'success',
          });
          this.dialogVisibleorgone = !this.dialogVisibleorgone;
          this.rolemanageone();
        });
      }
    },
    //停用启用
    updateStatus(goodsTypeId, status) {
      let data = {
        goodsTypeId: goodsTypeId,
        status: status,
      };
      addGoodsType(data).then((res) => {
        var msg = '';
        if (status == '1') {
          msg = '启用';
        } else if (status == '0') {
          msg = '停用';
        } else if (status == '2') {
          msg = '删除';
        }
        if (res.code == '1') {
          this.$message({
            showClose: true,
            message: msg + '成功',
            type: 'success',
          });
          this.rolemanageone();
        } else {
          this.$message.error(msg + '失败');
        }
      });
    },
    indexMethod(index) {
      let curpage = this.listQuery.current; //单前页码，具体看组件取值
      let limitpage = this.listQuery.size; //每页条数，具体是组件取值
      return index + 1 + (curpage - 1) * limitpage;
    },
    handledelete(v) {
      let data = {
        goodsTypeId: v.goodsTypeId,
      };
      this.$confirm('确认删除吗？').then((_) => {
        deleteGoodsType(qs.stringify(data)).then((res) => {
          this.$message({
            showClose: true,
            message: res.message,
            type: res.code == 0 ? 'success' : 'error',
          });
          this.rolemanageone();
        });
      });
    },
    add() {
      // this.dialogVisible = !this.dialogVisible;
      this.editflag = true;
    },
    edit(v) {
      console.log(v, 'kkdd');
      this.ruleForm.orgName = v.orgName;
      this.ruleForm.goodsTypeId = v.goodsTypeId;
      this.ruleForm.upOrgSeq = v.upOrgSeq;
      this.ruleForm.upOrgSeqName = v.upOrgSeqName;
      this.ruleForm.orgType = v.orgType;
      this.ruleForm.updateUser = v.updateUser;
      this.ruleForm.sortNo = v.sortNo;
      this.ruleForm.tagUrl = v.tagUrl;
      this.ruleForm.picUrl = v.picUrl;
      console.log(v, 'pp');
      // this.dialogVisible = !this.dialogVisible;
      this.editflag = false;
    },
    confirmEdit(v) {
      if (this.ruleForm.orgName == '' || this.ruleForm.orgName == null) {
        this.$message.error('请输入本级组织名称');
        return;
      }
      if (
        this.ruleForm.goodsTypeId == '' ||
        this.ruleForm.goodsTypeId == null
      ) {
        this.$message.error('请输入本级组织编码');
        return;
      }
      if (this.ruleForm.upOrgSeq == '' || this.ruleForm.upOrgSeq == null) {
        this.$message.error('请选择上级组织名称');
        return;
      }
      if (this.ruleForm.orgType == '' || this.ruleForm.orgType == null) {
        this.$message.error('请选择组织类型');
        return;
      }
      if (this.editflag) {
        //   var u1 = "u1";
        var userId = localStorage.getItem('userId');
        let data = {
          orgName: this.ruleForm.orgName,
          goodsTypeId: this.ruleForm.goodsTypeId,
          upOrgSeq: this.ruleForm.upOrgSeq,
          upOrgSeqName: this.ruleForm.upOrgSeqName,
          sortNo: this.ruleForm.sortNo,
          picUrl: this.ruleForm.picUrl,
          tagUrl: this.ruleForm.tagUrl,
          updateUser: this.ruleForm.updateUser,
        };
        addGoodsType(data).then((res) => {
          this.dialogVisible = !this.dialogVisible;
          this.$message({
            showClose: true,
            message: '添加成功',
            type: 'success',
          });
          this.rolemanageone();
        });
      } else {
        //var u1 = "u1";
        var userId = localStorage.getItem('userId');
        let data = {
          orgName: this.ruleForm.orgName,
          goodsTypeId: this.ruleForm.goodsTypeId,
          picUrl: this.ruleForm.picUrl,
          tagUrl: this.ruleForm.tagUrl,
          updateUser: this.ruleForm.updateUser,
        };
        updaterole(data).then((res) => {
          this.dialogVisible = !this.dialogVisible;
          this.$message({
            showClose: true,
            message: res.message,
            type: 'success',
          });
          this.rolemanageone();
        });
      }
    },
    handleSizeChange(val) {
      this.listQuery.size = val;
      this.rolemanageone();
    },
    handleCurrentChange(val) {
      this.listQuery.current = val;
      this.rolemanageone();
    },

    descInput() {
      this.txtVal = this.updateDiseaseForm.memo.length;
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisibleImg = true;
    },
    upLoadPicone(file, fileList) {
      this.imgListone = [];
      this.ruleForm.tagUrl = file.result;
      this.ruleFormorg.tagUrl = file.result;
    },
    handleImgChangeone(file, fileList) {
      if (file.response) {
        this.imgListone.push({
          url: file.response.result,
          status: 'finished',
        });
      }
    },
    upLoadPictwo(file, fileList) {
      this.imgListtwo = [];
      this.ruleForm.picUrl = file.result;
      this.ruleFormorg.picUrl = file.result;
    },
    handleImgChangetwo(file, fileList) {
      if (file.response) {
        this.imgListtwo.push({
          url: file.response.result,
          status: 'finished',
        });
      }
    },
    checkSortNo(val, type) {
      // 值，符号
      if (val === null || val === undefined || val === '') {
        return this.total + 1;
      } else {
        var aaa = Number(this.total + 1);
        if (Number(val) < aaa) {
          this.$confirm(
            '此操作将排序小于推荐值' + aaa + ', 是否继续?',
            '提示',
            {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning',
            }
          )
            .then(() => {
              return (
                (this.ruleForm.sortNo = val), (this.ruleFormorg.sortNo = val)
              );
            })
            .catch(() => {
              return (
                (this.ruleForm.sortNo = aaa), (this.ruleFormorg.sortNo = aaa)
              );
            });
        } else {
          return val;
        }
      }
    },
    handleExceed(file, fileList6) {
      this.$message.error(`图片最多上传1张`);
    },
    //排序
    handleSort(val) {
      let sortModel = '';
      if (val.order === 'ascending') {
        sortModel = 'ASC';
        this.formInline.ascs = [val.column.sortable];
        this.formInline.descs = [];
        this.search();
      } else if (val.order === 'descending') {
        sortModel = 'DESC';
        this.formInline.ascs = [];
        this.formInline.descs = [val.column.sortable];
        this.search();
      }
    },
  },
};
</script>
<style lang="less" scoped>
.toptitle {
  border: 1px solid #e0e0e0;
  border-bottom: 2px solid #188097;
  background: #f5f5f5;
  line-height: 35px;
  margin-bottom: 10px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: bold;
}
.el-form-item .el-select {
  width: 100%;
}
</style>
